package core.config;

import org.exolab.castor.xml.Unmarshaller;

/*
 * This class was automatically generated with <a
 * href="http://www.castor.org">Castor 1.3.1</a>, using an XML Schema. $Id$
 */
/**
 * Class EventMappings.
 *
 * @version $Revision$ $Date$
 */
@SuppressWarnings("serial")
public class EventMappings implements java.io.Serializable {

    //--------------------------/
    //- Class/Member Variables -/
    //--------------------------/
    /**
     * Field _items.
     */
    private java.util.Map<String, EventMappingsItem> _items;

    //----------------/
    //- Constructors -/
    //----------------/
    public EventMappings() {
        super();
        this._items = new java.util.HashMap<String, EventMappingsItem>();
    }

    //-----------/
    //- Methods -/
    //-----------/
    /**
     *
     *
     * @param vEventMappingsItem
     * @throws java.lang.IndexOutOfBoundsException if the index given is outside
     * the bounds of the collection
     */
    public void addEventMappingsItem(final EventMappingsItem vEventMappingsItem) throws java.lang.IndexOutOfBoundsException {
        this._items.put(vEventMappingsItem.getEventDescription().getName(), vEventMappingsItem);
    }
//
//    /**
//     *
//     *
//     * @param index
//     * @param vEventMappingsItem
//     * @throws java.lang.IndexOutOfBoundsException if the index given is outside
//     * the bounds of the collection
//     */
//    public void addEventMappingsItem(final EventMappingsItem vEventMappingsItem) throws java.lang.IndexOutOfBoundsException {
//        this._items.put(index, vEventMappingsItem);
//    }

    /**
     * Method enumerateEventMappingsItem.
     *
     * @return an Enumeration over all possible elements of this collection
     */
    public java.util.Enumeration<? extends EventMappingsItem> enumerateEventMappingsItem() {
        return java.util.Collections.enumeration(this._items.values());
    }

    /**
     * Method getEventMappingsItem.
     *
     * @param index
     * @throws java.lang.IndexOutOfBoundsException if the index given is outside
     * the bounds of the collection
     * @return the value of the EventMappingsItem at the given index
     */
    public EventMappingsItem getEventMappingsItem(final String eventName) throws java.lang.IndexOutOfBoundsException {
        return (EventMappingsItem) _items.get(eventName);
    }

    /**
     * Method getEventMappingsItem.Returns the contents of the collection in an
     * Array. <p>Note: Just in case the collection contents are changing in
     * another thread, we pass a 0-length Array of the correct type into the API
     * call. This way we <i>know</i> that the Array returned is of exactly the
     * correct length.
     *
     * @return this collection as an Array
     */
    public EventMappingsItem[] getEventMappingsItem() {
        EventMappingsItem[] array = new EventMappingsItem[0];
        return (EventMappingsItem[]) this._items.values().toArray(array);
    }

    /**
     * Method getEventMappingsItemCount.
     *
     * @return the size of this collection
     */
    public int getEventMappingsItemCount() {
        return this._items.size();
    }

    /**
     * Method isValid.
     *
     * @return true if this object is valid according to the schema
     */
    public boolean isValid() {
        try {
            validate();
        } catch (org.exolab.castor.xml.ValidationException vex) {
            return false;
        }
        return true;
    }

    /**
     * Method iterateEventMappingsItem.
     *
     * @return an Iterator over all possible elements in this collection
     */
    public java.util.Iterator<? extends EventMappingsItem> iterateEventMappingsItem() {
        return this._items.values().iterator();
    }

    /**
     *
     *
     * @param out
     * @throws org.exolab.castor.xml.MarshalException if object is null or if
     * any SAXException is thrown during marshaling
     * @throws org.exolab.castor.xml.ValidationException if this object is an
     * invalid instance according to the schema
     */
    public void marshal(final java.io.Writer out) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Marshaller.marshal(this, out);
    }

    /**
     *
     *
     * @param handler
     * @throws java.io.IOException if an IOException occurs during marshaling
     * @throws org.exolab.castor.xml.ValidationException if this object is an
     * invalid instance according to the schema
     * @throws org.exolab.castor.xml.MarshalException if object is null or if
     * any SAXException is thrown during marshaling
     */
    public void marshal(final org.xml.sax.ContentHandler handler) throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Marshaller.marshal(this, handler);
    }

    /**
     */
    public void removeAllEventMappingsItem() {
        this._items.clear();
    }

    /**
     * Method removeEventMappingsItem.
     *
     * @param vEventMappingsItem
     * @return true if the object was removed from the collection.
     */
    public boolean removeEventMappingsItem(final EventMappingsItem vEventMappingsItem) {
        boolean removed = _items.containsKey(vEventMappingsItem.getEventDescription().getName());
        _items.remove(vEventMappingsItem.getEventDescription().getName());
        return removed;
    }

    /**
     * Method removeEventMappingsItemAt.
     *
     * @param index
     * @return the element removed from the collection
     */
    public EventMappingsItem removeEventMappingsItem(String eventName) {
        java.lang.Object obj = this._items.get(eventName);
        this._items.remove(eventName);
        return (EventMappingsItem) obj;
    }

    /**
     *
     *
     * @param vEventMappingsItem
     * @throws java.lang.IndexOutOfBoundsException if the index given is outside
     * the bounds of the collection
     */
    public void setEventMappingsItem(final EventMappingsItem vEventMappingsItem) throws java.lang.IndexOutOfBoundsException {
        this._items.put(vEventMappingsItem.getEventDescription().getName(), vEventMappingsItem);
    }

    /**
     *
     *
     * @param vEventMappingsItemArray
     */
    public void setEventMappingsItem(final EventMappingsItem[] vEventMappingsItemArray) {
        //-- copy array
        _items.clear();

        for (int i = 0; i < vEventMappingsItemArray.length; i++) {
            this._items.put(vEventMappingsItemArray[i].getEventDescription().getName(), vEventMappingsItemArray[i]);
        }
    }

    /**
     * Method unmarshal.
     *
     * @param reader
     * @throws org.exolab.castor.xml.MarshalException if object is null or if
     * any SAXException is thrown during marshaling
     * @throws org.exolab.castor.xml.ValidationException if this object is an
     * invalid instance according to the schema
     * @return the unmarshaled EventMappings
     */
    public static EventMappings unmarshal(final java.io.Reader reader) throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        return (EventMappings) Unmarshaller.unmarshal(EventMappings.class, reader);
    }

    /**
     *
     *
     * @throws org.exolab.castor.xml.ValidationException if this object is an
     * invalid instance according to the schema
     */
    public void validate() throws org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
        validator.validate(this);
    }
}
